<template>
	<view class="content">
		<mydefault type="1" :showflag="showflag" ></mydefault>
		<!-- 报警信息列表 -->
		<view class="chp_item" v-for="(item,index) in list">
			<view class="chp_item_fl">
				<text>{{item.create_time.slice(0,4)}}</text>
				<text>{{item.create_time.slice(5,10)}}</text>
			</view>
			<view class="chp_item_fr">
				<text>{{item.notice_name}}</text>
				<text>
					{{item.notice_content}}
				</text>
			</view>
		</view>
		<uLi-load-more v-if="list.length>=5" :status="loadingType" :contentText="contentText" ></uLi-load-more>
	
		
		
	</view>
</template>

<script>
	import uLiLoadMore from "@/components/uLi-load-more/uLi-load-more.vue"
	import mydefault from '@/components/default/default.vue';
	export default {
		components:{
		mydefault,
		uLiLoadMore
		},
		data() {
			return {
				showflag:false,
               page:1,
			   list:'',
			   loadingText: '加载中...',
			   loadingType: 'more',//定义加载方式 0---contentdown  1---contentrefresh 2---contentnomore
			   contentText: {
			          contentdown:'上拉显示更多',
			          contentrefresh: '正在加载...',
			          contentnomore: '没有更多数据了',
			    },
			};
		},
		onLoad(){
			this.getNoticeList()
		},
		onReachBottom(){
			this.page=this.page+1
			this.getNoticeList()
		},
		methods:{
			getNoticeList(){
				var that=this;
				that.ajax({
					url:'api/Notice/getNoticeList',
					data:{
						page:that.page,
						type:1
					},
					success:function(res){
						console.log(res)
						if(res.code!=200||res.data.length<=0){
							that.showflag=true
							return
						}
						if(that.page==1){
							that.list=res.data
							console.log(that.list)
						} 
						if(that.page>1){ 
							if(res.data.length>0){
								that.list=that.list.concat(res.data)
								that.loadingType = 'more';//将loadingType归0重置
								uni.hideNavigationBarLoading();//关闭加载动画
							}else{  
								that.loadingType = 'noMore';//将loadingType归0重置
								uni.hideNavigationBarLoading();//关闭加载动画
							}
						}
					}
				  })
			}
		}
	}
</script>

<style lang="less" scoped> 
	.content {
		height: 100%;
		background-color: #F7F9FB;
		padding: 40rpx 30rpx;
		min-height: 100vh;
	}

	.chp_item {
		display: flex;
		padding: 30rpx; 
		min-height: 235rpx;
		color: #333;
		font-size: 30rpx;
		background-color: #fff;
		.chp_item_fl{
			width: 120rpx; 
			& text:nth-child(2) {
				display: block;
				font-size: 26rpx;
				color: #999;
			}
		}
		.chp_item_fr{
			flex: 1;
			& text:nth-child(2){
				margin-top: 28rpx;
				display: block;
				line-height: 40rpx;
				color: #666;
				font-size:26rpx
			}
		}
	}
</style>
